home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / tpb4_src.zip / INITIAL3.PAS < prev    next >
Pascal/Delphi Source File  |  1988-09-13  |  12KB  |  368 lines

  1. { TPBoard 4.2 Copyright (c) 1987,88 by Jon Schneider & Rick Petersen  
  2.   Portions Copyright (c) 1986,87 by Steve Fox and Les Archambault  
  3.   
  4.   Last modified  ::  6-15-88 11:39 pm 
  5. }
  6.  
  7. {$R-}                             {Range checking off}
  8. {$B-}                             {Boolean complete evaluation off}
  9. {$S-}                             {Stack checking off}
  10. {$I+}                             {I/O checking on}
  11. {$N-}                             {No numeric coprocessor}
  12.  
  13. Unit Initial3;
  14.  
  15. Interface
  16.  
  17. Uses
  18.   TPCrt, Dos, Globals, TPSTRING,
  19.   TPDOS, Core1, Core2;
  20.   
  21.   
  22. procedure ReadConfigFile;
  23.  
  24. procedure ReadOrigFile;
  25.  
  26. procedure ReadSectionFile;
  27.  
  28.  
  29.   {==========================================================================}
  30.   
  31.   
  32. Implementation
  33.  
  34.  
  35.   procedure ReadConfigFile;
  36.   
  37.   var
  38.     ets, co, am,
  39.     ll, r300, rp,
  40.     dok, ma,
  41.     dd, fo          : Char;
  42.     i               : Integer;
  43.     CreditVal       : Byte;
  44.     
  45.   begin ;
  46.     Assign(config_file, 'CONFIG.BB#');
  47.     {$I-}
  48.     Reset(config_file); {$I+}
  49.     if IoResult = 0 then
  50.       begin
  51.         Read(config_file, maxfree_uplds, maxfree_logs, maxfree_mslimit,
  52.           maxfree_lines, maxfree_abs, ExtraTimeStart, ExtraTimeStop,
  53.           extra_time_val, chatstart, chatend, sleepy_time, max_tries,
  54.           auto_macro_start, max_msg_lines, start_restrict300, end_restrict300,
  55.           up_down_ratio, val_time, uval_time, val_acc, uval_acc, val_days,
  56.           unv_days, unr_days, rea_days, new_days, this_node, this_net,
  57.           answer_delay, Attention, com_port, modem_rate, this_zone, line_abort,
  58.           CreditVal, UpCredit);
  59.         ReadLn(config_file, dok, dok, ets, co, am, ll, r300, rp, ma,
  60.           dd, fo, macro);         {first dok eats space}
  61.         ReadLn(config_file, fido_sysop);
  62.         fido_sysop := StUpcase(fido_sysop);
  63.         ReadLn(config_file, fidomail);
  64.         ReadLn(config_file, fidolists);
  65.         ReadLn(config_file, question);
  66.         ReadLn(config_file, menu_password);
  67.         ReadLn(config_file, OKAY);
  68.         ReadLn(config_file, RING);
  69.         ReadLn(config_file, connect300);
  70.         ReadLn(config_file, connect1200);
  71.         ReadLn(config_file, connect2400);
  72.         ReadLn(config_file, connect9600);
  73.         ReadLn(config_file, connect1200ecc);
  74.         if connect1200ecc = '' then
  75.           AllowMNP := False
  76.         else
  77.           AllowMNP := True;
  78.         ReadLn(config_file, connect2400ecc);
  79.         ReadLn(config_file, connect9600ecc);
  80.         ReadLn(config_file, Error);
  81.         ReadLn(config_file, init_str);
  82.         ReadLn(config_file, off_hook_str);
  83.         ReadLn(config_file, answer_str);
  84.         ReadLn(config_file, hang_up_str);
  85.         if Length(menu_password) > 1 then
  86.           for i := 1 to Length(menu_password) do
  87.             menu_password[i] := Char(Ord(menu_password[i]) xor $0a);
  88.         if macro = '' then
  89.           macro := Deflt_macro
  90.         else
  91.           macro := trim(macro);   {delete leading & trailing spaces}
  92.         if ets = 'T' then
  93.           extra_time_sw := True
  94.         else
  95.           extra_time_sw := False;
  96.         if co = 'T' then
  97.           chat_ok := True
  98.         else
  99.           chat_ok := False;
  100.         if am = 'T' then
  101.           auto_macro := True
  102.         else
  103.           auto_macro := False;
  104.         if ll = 'T' then
  105.           limit_lines := True
  106.         else
  107.           limit_lines := False;
  108.         if r300 = 'T' then
  109.           restrict300 := True
  110.         else
  111.           restrict300 := False;
  112.         if rp = 'T' then
  113.           restrict_public := True
  114.         else
  115.           restrict_public := False;
  116.         if dok = 'T' then
  117.           down_ok := True
  118.         else
  119.           down_ok := False;
  120.         if ma = 'T' then
  121.           modem_answer := True
  122.         else
  123.           modem_answer := False;
  124.         if dd = 'T' then
  125.           disp_dir := True
  126.         else
  127.           disp_dir := False;
  128.         if fo = 'T' then
  129.           format := True
  130.         else
  131.           format := False;
  132.         case CreditVal of
  133.           1 :
  134.             CreditType := Points;
  135.           2 :
  136.             CreditType := Kilobytes;
  137.           3 :
  138.             CreditType := Files;
  139.         end;
  140.         Close(config_file);
  141.       end
  142.     else
  143.       begin
  144.         WriteLn(BEL, 'Can''t find CONFIG.BB#. Run SETUP.EXE to correct.');
  145.         Halt;
  146.       end;
  147.   end;
  148.   
  149.   
  150.   
  151.   procedure ReadOrigFile;
  152.   
  153.   begin
  154.     my_zone := Long2Str(this_zone);
  155.     my_net := Long2Str(this_net);
  156.     my_node := Long2Str(this_node);
  157.     orig_line := '';
  158.     Assign(orig_file, 'ORIGIN');
  159.     {$I-}
  160.     Reset(orig_file);
  161.     {$I+}
  162.     if IoResult = 0 then
  163.       begin
  164.         ReadLn(orig_file, orig_line);
  165.         Close(orig_file);
  166.       end;
  167.     orig_line := ' * Origin: '+orig_line+' ('+my_zone+':'+my_net+'/'+my_node+')'
  168.     +CR+LF;
  169.     tear_line := CR+LF+CR+LF+'--- '+Version+CR+LF;
  170.     seenby_line := 'SEEN-BY: '+my_net+'/'+my_node+' '+CR+LF;
  171.   end;
  172.   
  173.   
  174.   
  175.   procedure ReadSectionFile;
  176.   
  177.   type
  178.     Section_rec =
  179.       record
  180.         sdrive          : Char;
  181.         suser           : Integer;
  182.         saccs           : Integer;
  183.         confnum         : Integer;
  184.         sname           : DosFileName;
  185.         sdesc           : StrPr;
  186.         mode            : Char;
  187.       end;
  188.       
  189.   var
  190.     Sect_File       : file of Section_rec;
  191.     sect_rec        : Section_rec;
  192.     found_file_secs,
  193.     found_post,
  194.     found_system,
  195.     Samedrive, OK   : Boolean;
  196.     artcount        : Integer;
  197.     drive           : Str3;
  198.     areathis,
  199.     arealast        : AreaPtr;
  200.     sectthis,
  201.     sectlast        : SectPtr;
  202.     artthis,
  203.     artlast         : ArtPtr;
  204.     temp            : string;
  205.     Section         : DosFileName;
  206.     
  207.   begin
  208.     printer_copy := False;        {turn off printer..just in case}
  209.     found_file_secs := True;
  210.     found_post := False;
  211.     found_system := False;
  212.     artcount := 0;
  213.     Assign(Sect_File, sect_name+ext);
  214.     {$I-}
  215.     Reset(Sect_File) {$I+} ;      { Build file and message section lists }
  216.     OK := (IoResult = 0);
  217.     if OK then
  218.       begin
  219.         Seek(Sect_File, 0);
  220.         while not EoF(Sect_File) do
  221.           with sect_rec do
  222.             begin
  223.               Read(Sect_File, sect_rec);
  224.               if mode = 'M' then
  225.                 begin             {message areas}
  226.                   if trim(sname) = 'POST' then
  227.                     found_post := True;
  228.                   if trim(sname) = 'SYSTEM' then
  229.                     found_system := True;
  230.                   New(areathis);
  231.                   if AreaBase = nil then
  232.                     AreaBase := areathis
  233.                   else
  234.                     arealast^.next := areathis;
  235.                   arealast := areathis;
  236.                   arealast^.Area := suser;
  237.                   if confnum > 0 then
  238.                     arealast^.AreaConf := confnum
  239.                   else
  240.                     arealast^.AreaConf := 0;
  241.                   if (confnum > 0) and (not cmd_tail) then
  242.                     begin
  243.                       WriteLn;
  244.                       WriteLn('Activating Message Conference number ', confnum);
  245.                       Delay(500);
  246.                     end;
  247.                   arealast^.AreaAccs := saccs;
  248.                   arealast^.AreaName := trim(sname);
  249.                   arealast^.AreaDesc := trim(sdesc);
  250.                   arealast^.next := nil
  251.                 end
  252.               else if mode = 'F' then
  253.                 begin
  254.                   New(sectthis);  {file sections}
  255.                   if SectBase = nil then
  256.                     SectBase := sectthis
  257.                   else
  258.                     sectlast^.next := sectthis;
  259.                   sectlast := sectthis;
  260.                   sectlast^.SectDrive := sdrive;
  261.                   sectlast^.SectUser := suser;
  262.                   if confnum > 0 then
  263.                     sectlast^.SectConf := confnum
  264.                   else
  265.                     sectlast^.SectConf := 0;
  266.                   if (confnum > 0) and (not cmd_tail) then
  267.                     begin
  268.                       WriteLn;
  269.                       WriteLn('Activating Files Conference number ', confnum);
  270.                       Delay(500);
  271.                     end;
  272.                   sectlast^.SectAccs := saccs;
  273.                   sectlast^.SectName := trim(sname);
  274.                   sectlast^.SectDesc := trim(sdesc);
  275.                   sectlast^.next := nil;
  276.                 end
  277.               else if mode = 'A' then
  278.                 begin
  279.                   New(artthis);
  280.                   if Artbase = nil then
  281.                     Artbase := artthis
  282.                   else
  283.                     artlast^.next := artthis;
  284.                   Inc(artcount);
  285.                   artlast := artthis;
  286.                   artlast^.Artdrive := sdrive;
  287.                   artlast^.ArtUser := suser;
  288.                   artlast^.ArtAccs := saccs;
  289.                   artlast^.Artnum := artcount;
  290.                   artlast^.ArtName := trim(sname);
  291.                   artlast^.ArtDesc := trim(sdesc);
  292.                   artlast^.next := nil;
  293.                 end;
  294.             end;                  {eof reached}
  295.         Close(Sect_File);
  296.         Section := 'NEWIN';
  297.         FindSect(Section, RcvDrv, OK); {sets up area to recv. files}
  298.         if OK then
  299.           begin
  300.             RcvName := RcvDrv;
  301.             if (Length(HomName) > 3) and (RcvName = HomDrv) then
  302.               begin
  303.                 RcvName := RcvName+Copy(HomName, 4, Length(HomName));
  304.                 RcvName := RcvName+'\';
  305.               end;
  306.             RcvName := RcvName+'NEWIN';
  307.           end
  308.         else
  309.           begin
  310.             WriteLn(BEL, 'NEWIN file section name not found.');
  311.             found_file_secs := False;
  312.           end;
  313.         Section := 'LOGIN';
  314.         FindSect(Section, drive, OK);
  315.         if not OK then
  316.           begin
  317.             WriteLn(BEL, 'LOGIN file section name not found.');
  318.             found_file_secs := False;
  319.           end;
  320.         Section := 'SYSTEM';
  321.         FindSect(Section, drive, OK);
  322.         if not OK then
  323.           begin
  324.             WriteLn(BEL, 'SYSTEM file section name not found.');
  325.             found_file_secs := False;
  326.           end;
  327.         if not found_post then
  328.           WriteLn('POST message area name not found.');
  329.         if not found_system then
  330.           WriteLn('SYSTEM message area name not found.');
  331.         if (not found_file_secs) or (not found_post) or (not found_system) then
  332.           begin
  333.             WriteLn;
  334.             WriteLn(BEL, 'Unable to continue. Re-run SETUP.EXE');
  335.             Halt;
  336.           end;
  337.       end                         {was able to read section.bb# file}
  338.     else
  339.       begin
  340.         WriteLn(BEL, 'Section file not found. Run SETUP.EXE to create.');
  341.         WriteLn(BEL, 'Unable to continue.');
  342.         Halt;
  343.       end;
  344.       
  345.     temp := StUpCase(GetEnvironmentString('dszlog='));
  346.     if Length(HomName) > 3 then
  347.       st := HomName+'\'
  348.     else
  349.       st := HomName;
  350.     if temp <> st+'DSZ.LOG' then
  351.       begin
  352.         WriteLn(BEL, 'DSZLOG environment variable missing or invalid.');
  353.         WriteLn(BEL, 'Unable to continue.');
  354.         if Length(HomName) > 3 then
  355.           st := HomName+'\'
  356.         else
  357.           st := HomName;
  358.         WriteLn(BEL, 'Use SET DSZLOG=', st, 'DSZ.LOG in your AUTOEXEC.BAT file.');
  359.         Halt
  360.       end;
  361.       
  362.     Ch_Init;                      {initialize the communications}
  363.   end;
  364.   
  365.   
  366. end.                              { OF INITIAL3.PAS }
  367. 
  368.